package org.darcy.service.impl;

import java.util.List;

import org.darcy.dao.SysSocialConfigMapper;
import org.darcy.entity.SysSocialConfig;
import org.darcy.framework.generic.GenericServiceImpl;
import org.darcy.service.SysSocialConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xkcoding.json.util.StringUtil;

@Service
public class SysSocialConfigServiceImpl extends GenericServiceImpl<SysSocialConfig> implements SysSocialConfigService {

	@Autowired
	private SysSocialConfigMapper sysSocialConfigMapper;


	@Override
	public SysSocialConfig getByClientId(String clientId) {
		Assert.notNull(clientId, "This argument is required; it must not be null");
		SysSocialConfig entity = sysSocialConfigMapper.getByClientId(clientId);
		return entity;
	}

	@Override
	public SysSocialConfig getByPlatform(String platform) {
		if (StringUtil.isEmpty(platform)) {
			return null;
		}
		QueryWrapper<SysSocialConfig> q = new QueryWrapper<SysSocialConfig>();
		q.eq("platform", platform.toLowerCase());
		SysSocialConfig sysSocialConfig = sysSocialConfigMapper.selectOne(q);
		if (null == sysSocialConfig) {
			return null;
		}
		return sysSocialConfig;
	}

	@Override
	public List<SysSocialConfig> listAvailable() {
		List<SysSocialConfig> list = sysSocialConfigMapper.listAvailable();
		return list;
	}

}
